﻿<%@ Page Title="Title" Language="C#" Inherits="System.Web.Mvc.ViewPage<List<User>>"
    MasterPageFile="~/Views/Shared/Site.Master" %>

<%@ Import Namespace="ControlModule.Daos" %>
<%@ Import Namespace="ControlModule.Models" %>
<asp:Content runat="server" ID="Title" ContentPlaceHolderID="TitleContent">
    Список групп
</asp:Content>
<asp:Content runat="server" ID="Main" ContentPlaceHolderID="MainContent">
    <div>
        <% Html.RenderPartial("TutorMenuControl"); %>
    </div>
    <div>
        <h1>
            Group</h1>
        <table style="width: 100%;">
            <tr>
                <td class="table-header-row">
                    <h2>
                        id</h2>
                </td>
                <td class="table-header-row">
                    <h2>
                        e-mail</h2>
                </td>
                <td class="table-header-row">
                    <h2>
                        ФИО</h2>
                </td>
                <td class="table-header-row">
                    <h2>
                        операции</h2>
                </td>
                <td class="table-header-row">
                    <h2>
                        Statistic</h2>
                </td>
            </tr>
            <%     
                if (Model != null)
                    foreach (User user in Model)
                    {
            %>
            <tr>
                <td class="table-item-row">
                    <%= Html.Encode(user.Id) %>
                </td>
                <td class="table-item-row">
                    <%= Html.Encode(user.EmailAddr) %>
                </td>
                <td class="table-item-row">
                    <%= Html.Encode(user.FirstName + " " + user.LastName + " " + user.Patronymic)%>
                </td>
                <td>
                    <%
                        int labworkId = (int)ViewData["labworkId"];
                        int sumQuesCount = new CmDbEntities().RelLabworkQuestion.Count(
                            r => r.LabworkId == labworkId);
                        int userFnsQstCount = new CmDbEntities().RelLabworkUserQuestionAnswer.Count(
                            r => r.LabworkId == labworkId && r.UserId == user.Id);
                    %>
                    <%= Html.Encode("Вопросы допуска: " + QuestionDao.GetRightAnswersCount(labworkId,user.Id) + "/" + sumQuesCount) %>
                </td>
                <td>
                    <%= Html.ActionLink("Статистика", "Statistic", "Tutor")%>
                </td>
            </tr>
            <% } %>
        </table>
    </div>
</asp:Content>
